package com.ccxy.springboot.controller;

import com.ccxy.springboot.service.imp.BootServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
public class bootController {
    //自动注入
    @Autowired
    BootServiceImpl service;
    @RequestMapping(value = "/login")
    public String login(@RequestParam Map map) {
        List<Map> login = service.login(map);
        System.out.println(login);
        if(login.size()==0){
            return "失败";
        }else{
            return "成功";
        }

}
    @RequestMapping(value = "/querycity")
    public List<Map> querycity(@RequestParam Map map){
        List<Map> query = service.querycity();
        System.out.println(query);
        return query;
        }

        @GetMapping("/citys")
        public Page<Map> lists(Integer pageNum, Integer pageSize){
        //设置分页规则
        PageHelper.startPage(pageNum,15);
        //返回所有分页信息参数为查询所有记录的信息
        Page<Map> userList = (Page<Map>) service.querycity();
        System.out.println(userList);
        return userList;
        }
        }